#include <stdio.h>
#include <string.h>

#define GEN(L, R)                            \
    case R:                                  \
        cnt = 0;                             \
        for (int j = i - 1; j >= 0; --j)     \
        {                                    \
            if (tmp[j] == R)                 \
                ++cnt;                       \
            else if (tmp[j] == L && !mrk[j]) \
            {                                \
                if (!cnt)                    \
                {                            \
                    mrk[i] = 1;              \
                    mrk[j] = 1;              \
                    break;                   \
                }                            \
                else                         \
                    --cnt;                   \
            }                                \
        }                                    \
        break;

char tmp[10001] = {0};
char mrk[10001] = {0};
char out[100011] = {0};
int n = 0;

char match(char L)
{
    switch (L)
    {
    case '(':
        return ')';
    case '[':
        return ']';
    case '{':
        return '}';
    case ')':
        return '(';
    case ']':
        return '[';
    case '}':
        return '{';
    default:
        return 0;
    }
}

int main()
{
    scanf("%s", tmp);
    n = strlen(tmp);
    for (int i = n - 1; i >= 0; --i)
    {
        int cnt = 0;
        switch (tmp[i])
        {
            GEN('(', ')')
            GEN('[', ']')
            GEN('{', '}')
        default:
            break;
        }
    }
    int p = 0, q = 0;
    while (p < n)
    {
        if (mrk[p])
            out[q++] = tmp[p];
        else
        {
            switch (tmp[p])
            {
            case '(':
            case '[':
            case '{':
                out[q++] = tmp[p];
                out[q++] = match(tmp[p]);
                break;
            case ')':
            case ']':
            case '}':
                out[q++] = match(tmp[p]);
                out[q++] = tmp[p];
                break;
            default:
                break;
            }
        }
        ++p;
    }
    out[q] = 0;
    puts(out);
    return 0;
}